package org.example.ims.Repository.Base;

import org.example.ims.Entity.Base.Warehouse;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

public interface WarehouseRepository extends JpaRepository<Warehouse, Integer> {
    @Query("SELECT w FROM Warehouse w " +
            "WHERE (:name IS NULL OR w.warehouseName = :name)" +
            "AND (:status IS NULL OR w.status = :status)")
    Page<Warehouse> searchWarehouses(@Param("name") String name,
                                 @Param("status") String status,
                                 Pageable pageable);
}
